<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>01_Object构造函数模式</title>
</head>
<body>
<!-- 
方式一：Object构造函数模式
    * 套路：先创建Object空对象，再动态添加属性或方法
    * 适用场景：起始时不确定对象内部数据
    * 问题：语句太多
-->
<script>
// name:"Tom", age: 12
var p = new Object();
p.name = "Tom"
p.age = 12
p.setName = function(name) {
    this.name = name
}

p.setName("Jack")
console.log(p.name, p.age)
</script>
</body>
</html>